package controllers

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type BaseController struct {
}

/**
 * @Description: 接口返回数据结构定义
 */
type JsonRespones struct {
	Code    interface{} `json:"code"`
	Message interface{} `json:"message"`
	Data    interface{} `json:"data"`
}

func (b BaseController) success(c *gin.Context, api ...interface{}) {
	c.AbortWithStatusJSON(http.StatusOK, JsonRespones{
		Code:    0,
		Message: api[0],
		Data:    api[1],
	})
	return
}

func (b BaseController) error(c *gin.Context, api ...interface{}) {
	c.AbortWithStatusJSON(http.StatusOK, JsonRespones{
		Code:    1,
		Message: api[0],
		Data:    api[1],
	})
	return
}
